package com.seocoo.worker.user;

import android.os.Bundle;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.view.View;

import com.seocoo.worker.R;
import com.seocoo.worker.user.entity.EPromoList;
import com.seocoo.worker.user.model.UserModel;
import com.sfh.lib.mvvm.LiveDataMatch;
import com.sfh.lib.ui.MVVMFragment;

import java.util.List;

public class EvaluateFriendFragment extends MVVMFragment {

    private android.support.v7.widget.RecyclerView recyclerView;

    public static EvaluateFriendFragment newInstance(String orderType) {
        EvaluateFriendFragment fragment = new EvaluateFriendFragment();
        Bundle bundle = new Bundle();
        bundle.putString("Type", orderType);
        fragment.setArguments(bundle);
        return fragment;
    }

    @Override
    public int getLayout() {
        return R.layout.user_evaluate_friend_fragment;
    }

    EvaluateFriendAdapter adapter;

    @Override
    public void initData(View var1) {
        recyclerView = (RecyclerView) var1.findViewById(R.id.recycler_view);
        recyclerView.setLayoutManager(new LinearLayoutManager(getContext()));
        adapter = new EvaluateFriendAdapter();
        recyclerView.setAdapter(adapter);

        getViewModel(UserModel.class).queryPromoList(getArguments().getString("Type"));
    }

    @LiveDataMatch
    public void onPromoList(List<EPromoList> promoLists){
        adapter.setNewData(promoLists);
    }

}
